<?php

class PNExcelArray extends PNObjectExArray
{
    function PNExcelArray($init=null, $where='')
    {
        
        $this->PNObjectExArray();

        $this->_objType       = 'votedatacenter_excel';
        $this->_objField      = 'id';
        $this->_objPath       = 'excel';

/*
        $this->_objJoin[]     = array ( 'join_table'          =>  'users',
                                        'join_field'          =>  'uname',
                                        'object_field_name'   =>  'upload_name',
                                        'compare_field_table' =>  'user_id',
                                        'compare_field_join'  =>  'uid');
      $this->uploadFiles();
*/
      $this->_init($init, $where);
    }
/*
    function get($where='', $sort='', $limitOffset=-1, $limitNumRows=-1, $assocKey=null, $force=false, $distinct=false){
        return $this->select($where, $sort, $limitOffset, $limitNumRows, $assocKey);
    }
    
    function genSort(){
        return 'ORDER BY id';
    }
    
    function genFilter(){
        return '';
    }

  function uploadFiles(){

      $file = $_FILES['file'];
      $tmp_name = $file["tmp_name"];
      $fliename = $file["name"];
      $filetype = $file["type"];
      $filesize = $file["size"];
      $rootpath = "pnTemp/uploadfiles/";

      //Gennerate next id
      $file_id = DBUtil::selectFieldMax( 'degis_excel', 'id', 'MAX', '');
      if($file_id == null){
        $next_id = 1;
      }else{
        $next_id = $file_id+1;
      }

////////////////////////// get the extension of the file in a lower case format/////////////////////////////////////////////
      $filename = stripslashes($fliename);
      $i = strrpos($filename,".");
      if (!$i) { return ""; }
      $l = strlen($filename) - $i;
      $ext = substr($filename,$i+1,$l);
      $extension = strtolower($ext);

////////////////////////////generate new file&path/////////////////////////////////////////////////////////////////////
      $rootname       = $next_id.time().".".$extension;
      $path = $rootpath.$rootname;

      copy($tmp_name,$path);

      $objects = array(
                      'id'         => $next_id,
                      'user_id'    => 3,
                      'name'       => $rootname,
                      'file_path'  => $path,
                      'lastupdate' => date("Y-m-d"),
                      'status'     => 0,
                      'step_no'    => 1
                     );

    DBUtil::insertObject($objects,'degis_excel');

  }
*/
}

?>